package cool.gaogao.transactional.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author 高山青
 * @Date 2021/12/31  -   21:36
 */
@Repository
public class AccountDaoImpl implements AccountDao{
	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Override
	public int addMoney(int money) {
		String sql="update account set money=money+? where id=1";
		return jdbcTemplate.update(sql,money);
	}

	@Override
	public int updateMoney(int money) {
		String sql="update account set money=money-? where id=2";
		return jdbcTemplate.update(sql,money);
	}
}
